<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/WEB-INF/layout/include/taglib.jsp"%>
<html>
<head>
	<title></title>
	<script type="text/javascript" src="${libPath}/jquery/jquery-3.1.1.min.js"></script>
	<script src='${jsPath}/upload/ajaxfileupload.js'></script>
</head>
<body>
	<input style='width:200px;display:inline-block;margin-left:253px;margin-bottom:45px' type="file" id="file" name="file" style="height:40px" onchange="checkFile(this)">
	<a onclick='uplaod();'>上传</a>
	<script type="text/javascript">
		var managePath = '${ctxPath}/app/file/Upload';
		
		function uplaod() {
			$.ajaxFileUpload({
	            url: '${ctxPath}/test/upload', 
	            type: 'post',
	            secureuri: false, //一般设置为false
	            fileElementId: 'file', // 上传文件的id、name属性名
	            dataType: 'json', //返回值类型，一般设置为json、application/json
	            success: function(data, status){
	            	console.log(data);
	            },
				error: function (data, status, e) {  
					console.log(data);
		        }  
	        });
		}
		
		function checkFile(file) {
			/* var fileExt = file.value.substring(file.value.lastIndexOf(".")).toLowerCase();
	        if (file.files && file.files[0]) {
	        	if (file.files[0].size > 1024 * 1024 * 200) {
	        		file.value = "";
	        		error("上传文件大小不能超过100M");
	        	} else if (!fileExt.match(/.mpg|.mpeg|.avi|.rm|.rmvb|.mov|.mp4/i)) {
	        		file.value = "";
	        		error("只支持mpg,mpeg,avi,rm,rmvb,mov,wmv,mp4格式的文件上传");
	        	}
	         }  */
	    } 
	</script>
</body>
</html>